/**
 *  vector_general.inl
 *  AwkwardEngine - Math
 *
 *  Date: 19/08/2013
 *
 *  Language: C++
 *
 *  @author Carl McCaffrey
 *
 */
#ifndef VECTOR_GENERAL_INL
#define VECTOR_GENERAL_INL

/* Initialization */
inline cVec cVecZero(void)
{
	cVec vec;
	vec.x = 0;
	vec.y = 0;
	vec.z = 0;
	vec.w = 0;

	return vec;
}

inline cVec cVecSet(float x, float y, float z, float w)
{
	cVec vec;
	vec.x = x;
	vec.y = y;
	vec.z = z;
	vec.w = w;

	return vec;
}

/* General Operations */
inline cVec cVecAdd( cVec vec1, cVec vec2)
{
	return cVecSet(vec1.x + vec2.x, vec1.y + vec2.y, vec1.z + vec2.z, vec1.w);
}

inline cVec cVecSubtract(cVec vec1, cVec vec2)
{
	return cVecSet(vec1.x - vec2.x, vec1.y - vec2.y, vec1.z - vec2.z, vec1.w);
}

inline cVec cVecMultiply(cVec vec1, cVec vec2)
{
	return cVecSet(vec1.x * vec2.x, vec1.y * vec2.y, vec1.z * vec2.z, vec1.w);
}

inline cVec cVecDivide(cVec vec1, cVec vec2)
{
	return cVecSet(vec1.x / vec2.x, vec1.y / vec2.y, vec1.z / vec2.z, vec1.w);
}

inline cVec cVecSelect( cVec vec1, cVec vec2, cVec control)
{
	cVec vec;
	unsigned int temp[4];
	temp[0] = ((unsigned int)vec1.x & ~(unsigned int)control.x) | ((unsigned int)vec2.x & (unsigned int)control.x);
	temp[1] = ((unsigned int)vec1.y & ~(unsigned int)control.y) | ((unsigned int)vec2.y & (unsigned int)control.y);
	temp[2] = ((unsigned int)vec1.z & ~(unsigned int)control.z) | ((unsigned int)vec2.z & (unsigned int)control.z);
	temp[3] = ((unsigned int)vec1.w & ~(unsigned int)control.w) | ((unsigned int)vec2.w & (unsigned int)control.w);
	vec = cVecSet((float)temp[0], (float)temp[1], (float)temp[2], (float)temp[3]);

	return vec;
}

#endif // VECTOR_GENERAL_INL